import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
    count: 0,
}

const mutations ={
    // 增加一
    INCREMENT(state){
        state.count++;
    },
    // 减少一
    DECREMENT(state){
        state.count--
    }  
}

const actions = {
    incrementOdd(commit, state){
        if(state.count%2===1){
            commit('INCREMENT')
        }
    },
    incrementAsync(commit){
        setTimeout(()=>{
            commit('INCREMENT')
        },1000)
    }
}
